package com.live.dengdengtv.activity.my;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ProgressBar;
import android.widget.TextView;

import com.google.gson.JsonObject;
import com.live.dengdengtv.BaseActivity;
import com.live.dengdengtv.CustomTitleActivity;
import com.live.dengdengtv.R;
import com.live.dengdengtv.bean.AppInfo;
import com.live.dengdengtv.bean.SimpleInfoData;
import com.live.dengdengtv.net.NetTaskList;


/**
 * Created by leiyun on 2016/8/15.
 */
public class MyLevelActivity extends BaseActivity {

    private ProgressBar level_pb;
    private TextView score_tv;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my_level);

        findViewById(R.id.more_rl).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(context, MyRightsActivity.class);
                startActivity(intent);
            }
        });
        findViewById(R.id.back_ibtn).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });

        level_pb = (ProgressBar)findViewById(R.id.level_pb);
        score_tv = (TextView)findViewById(R.id.score_tv);

        getMyLevel();
    }


    private void getMyLevel(){
        requestData(NetTaskList.user_level, AppInfo.getHeadInfo(),1);
    }
    @Override
    public boolean onResponse(SimpleInfoData response, int id) {
        if (id == 1) {
            if(response.result == 0){
                JsonObject dataJson = response.data.getAsJsonObject();
                String member_level = dataJson.get("member_level").getAsString();
                int score = dataJson.get("score").getAsInt();
                int next_score = dataJson.get("next_score").getAsInt();

                level_pb.setProgress(score);
                level_pb.setMax(next_score);
                score_tv.setText(score+"/"+next_score);
            }
        }
        return false;
    }

}
